home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Reversed wipes ƒ / Circular wipe reversed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  3.7 KB  |  128 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Circular wipe reversed.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 2
  32. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  33. #define theWindowWidth (boundsRect.right-boundsRect.left)
  34.  
  35. pascal short CircularWipeReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  36.  
  37. /* Trace a region from the center to the topleft corner, down <BlockSize> pixels,
  38.    and back to the center.  Fill that in and move the region parameters +BlockSize.
  39.    Repeat for all sides (counterclockwise). */
  40.  
  41. pascal short CircularWipeReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  42. {
  43.     RgnHandle    curregion;
  44.     int            cx,cy,lastx,lasty;
  45.     int            BlockSize;
  46.     
  47.     BlockSize=theWindowWidth/40;
  48.     cx = boundsRect.left + theWindowWidth / 2;
  49.     cy = boundsRect.top + theWindowHeight / 2;
  50.  
  51.     curregion=NewRgn();
  52.     lasty=boundsRect.top;
  53.     do                                            /* left quadrant */
  54.     {
  55.         StartTiming();
  56.         SetEmptyRgn(curregion);
  57.         MoveTo(cx,cy);
  58.         OpenRgn();
  59.             LineTo(boundsRect.left,lasty);
  60.             Line(0, BlockSize);
  61.             LineTo(cx,cy);
  62.         CloseRgn(curregion);
  63.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  64.             &boundsRect, &boundsRect, 0, curregion);
  65.         lasty+=BlockSize;
  66.         TimeCorrection(CorrectTime);
  67.     }
  68.     while (lasty<boundsRect.bottom);
  69.     
  70.     lastx=boundsRect.left;
  71.     do                                            /* bottom quadrant */
  72.     {
  73.         StartTiming();
  74.         SetEmptyRgn(curregion);
  75.         MoveTo(cx,cy);
  76.         OpenRgn();
  77.             LineTo(lastx,boundsRect.bottom);
  78.             Line(BlockSize, 0);
  79.             LineTo(cx,cy);
  80.         CloseRgn(curregion);
  81.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  82.             &boundsRect, &boundsRect, 0, curregion);
  83.         lastx+=BlockSize;
  84.         TimeCorrection(CorrectTime);
  85.     }
  86.     while (lastx<boundsRect.right);
  87.     
  88.     lasty=boundsRect.bottom;
  89.     do                                            /* right quadrant */
  90.     {
  91.         StartTiming();
  92.         SetEmptyRgn(curregion);
  93.         MoveTo(cx,cy);
  94.         OpenRgn();
  95.             LineTo(boundsRect.right,lasty);
  96.             Line(0,-BlockSize);
  97.             LineTo(cx,cy);
  98.         CloseRgn(curregion);
  99.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  100.             &boundsRect, &boundsRect, 0, curregion);
  101.         lasty-=BlockSize;
  102.         TimeCorrection(CorrectTime);
  103.     }
  104.     while (lasty>boundsRect.top-BlockSize);
  105.     
  106.     lastx=boundsRect.right;
  107.     do                                            /* top quadrant */
  108.     {
  109.         StartTiming();
  110.         SetEmptyRgn(curregion);
  111.         MoveTo(cx,cy);
  112.         OpenRgn();
  113.             LineTo(lastx,boundsRect.top);
  114.             Line(-BlockSize,0);
  115.             LineTo(cx,cy);
  116.         CloseRgn(curregion);
  117.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  118.             &boundsRect, &boundsRect, 0, curregion);
  119.         lastx-=BlockSize;
  120.         TimeCorrection(CorrectTime);
  121.     }
  122.     while (lastx>boundsRect.left-BlockSize);
  123.     
  124.     DisposeRgn(curregion);
  125.     
  126.     return 0;
  127. }
  128.